﻿using Longbow.Web;

namespace Microsoft.Extensions.DependencyInjection
{
    /// <summary>
    /// 在线用户服务类
    /// </summary>
    public static class OnlineUsersServicesCollectionExtensions
    {
        /// <summary>
        /// 
        /// </summary>
        internal const string IPSvrHttpClientName = "IPSvr";

        /// <summary>
        /// 添加在线用户服务
        /// </summary>
        /// <param name="services"></param>
        /// <returns></returns>
        public static IServiceCollection AddOnlineUsers(this IServiceCollection services)
        {
            services.AddSingleton<IOnlineUsers, DefaultOnlineUsers>();
            services.AddHttpClient(IPSvrHttpClientName, client =>
            {
                client.DefaultRequestHeaders.Connection.Add("keep-alive");
            });
            return services;
        }
    }
}
